<?php
function get_image($data,$name){

$data = mb_convert_encoding($data, 'HTML-ENTITIES', "UTF-8"); 
$dom = new DOMDocument;
 $dom->loadHTML($data); 
 $sxe = simplexml_import_dom($dom);
 $folder = 'addition';
 // grab all <a> nodes with an href attribute
 $j=1;
 $std=date("Y")."/".date("m")."/".date("d")."/";

 if(!is_dir("../$folder/".$std)){
	mkdir("../$folder/".$std,0755,true);
 }
	 foreach ($sxe->xpath('//img[@src]') as $a)
	 {	    
		$find="image.manga24h.com";
		$link= $a['src'];
		$pos = strpos($link, $find);
		
		if($pos === false){
		
			$result=file_put_contents("$folder/".$std.$name."-".$j.".jpg",file_get_contents($link));	
		$imglink="http://image.manga24h.com/$folder/".$std.$name."-".$j.".jpg";	 
		$a['src']=$imglink;	
		}
		$j++;
	 }
 $new_html = $dom->saveHTML();
 return $new_html; 
 }
 

$data=get_image($_POST['content'], date("Y")."_".date("m")."_".date("d"));
echo $data;


?>